var http = require("http");
var express = require("express");
var app = express();
var logintestroute = require("./logintestroute.js");
var dbutil = require("./dbutil.js");

app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.json());
app.use(express.urlencoded());
app.use(express.cookieParser());
app.use(express.session({secret: "Tireheb1996"}));

//Authenticator

// setup routes with appropriate authentication
//var auth = express.basicAuth('admin', '9192631770');
app.use(express.basicAuth(function (user, pass, callback) {
    var result = (user === "testuser" && pass === "testpass");
    callback(null /*error*/, result);
}));


app.get("/", function (req, res) {
    res.render("test1");
});

app.post("/login", dbutil.dbutil);

app.listen(8880);

/*http.createServer(app).listen(8888, function () {
 res.render("test1");
 });
 */